

#include <scott/SString.h>

BOOST_AUTO_TEST_SUITE( SString_Test_Suite )

BOOST_AUTO_TEST_CASE( GetType_Test )
{
	SStringSp s = SString::Create("Hello");
	BOOST_CHECK( s->GetType() == STypeString );
}

BOOST_AUTO_TEST_CASE( GetAndSet_Test )
{
	SStringSp s = SString::Create("Hello");
	BOOST_CHECK( s->Get() == "Hello" );

	s->Set("Scott");
	BOOST_CHECK( s->Get() == "Scott" );
}

BOOST_AUTO_TEST_CASE( ToString_Test )
{
	SStringSp s = SString::Create("Hello");
	BOOST_CHECK( s->ToString() == "\"Hello\"" );
	BOOST_CHECK( s->ToString("n") == "Hello" );
}

BOOST_AUTO_TEST_CASE( SString_Parse_Test )
{
	// Test
	BOOST_CHECK( SString::Parse("\"\"")->Get() == "" );
	BOOST_CHECK( SString::Parse("\"a\"")->Get() == "a" );
	BOOST_CHECK( SString::Parse("\" c \"")->Get() == " c " );
	BOOST_CHECK( SString::Parse("\"Hello\"")->Get() == "Hello" );

	BOOST_CHECK_THROW( SString::Parse(""), SParseException );
	BOOST_CHECK_THROW( SString::Parse("\""), SParseException );
	BOOST_CHECK_THROW( SString::Parse("\"Hello"), SParseException );
	BOOST_CHECK_THROW( SString::Parse("Hello\""), SParseException );
	BOOST_CHECK_THROW( SString::Parse("blue"), SParseException );
	BOOST_CHECK_THROW( SString::Parse("12"), SParseException );
	BOOST_CHECK_THROW( SString::Parse("'A'"), SParseException );
	BOOST_CHECK_THROW( SString::Parse("{}"), SParseException );
	BOOST_CHECK_THROW( SString::Parse("{10}"), SParseException );
	BOOST_CHECK_THROW( SString::Parse("{'A'}"), SParseException );
	BOOST_CHECK_THROW( SString::Parse("{\"Hello\"}"), SParseException );
	BOOST_CHECK_THROW( SString::Parse("{red}"), SParseException );
}

BOOST_AUTO_TEST_SUITE_END()
